﻿using Dapper;
using System;
using System.Data;
using PlatformNetCore.Common;
using PlatformNetCore.Common.Helper;

namespace PlatformNetCore.Repository.Dapper
{
    public partial class Dapper
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="custmCode"></param>
        /// <returns></returns>
        public int AddSysLog(string logType, string request, string response, string remark, string successFlag)
        {
            try
            {
                string sql = @" INSERT INTO SysLog(ID,LogType,Request,Response,Remark,SuccessFlag,AddDate) VALUES (@ID,@LogType,@Request,@Response,@Remark,@SuccessFlag,GETDATE()) ";
                using (IDbConnection connection = GetSqlConnection())
                {
                    return connection.Execute(sql, new
                    {
                        ID = IdentityCreator.NextIdentity,
                        LogType = logType,
                        Request = request,
                        Response = response,
                        Remark = remark,
                        SuccessFlag = successFlag
                    });
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
                return 0;
            }
        }
    }
}
